<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!--区域-->
    <div id="app"> {{ message | capi }} </div>

    <div id="app2">
        <p>message 的值是： {{ message | capi }}</p>
    </div>

    <!--引入-->
    <script src="./lib/vue-2.6.12.js"></script>

    <!--创建实例对象-->
    <script>
        //全局过滤器
        Vue.filter('capi', function (str) {
            const first = str.charAt(0).toUpperCase()
            const other = str.slice(1)
            return first + other + '~~~'
        })

        const vm = new Vue({
            el: '#app',
            data: {
                message: 'hello vue'
            },
            filters: {
                capi (val) {
                    //一定要有返回值
                    const first = val.charAt(0).toUpperCase()
                    const other = val.slice(1)
                    return first + other 
                }
            }
        })

        //------------------------------
        const vm2 = new Vue({
            el: '#app2',
            data: {
                message: 'heima'
            },
        })
    </script>
</body>
</html>